﻿Imports System.Data

Public Class CTCatalogoGenerico

Private _IdCat          As Integer
Private _Descripcion    As String
Private _Clave          As Integer
Private _Valor          As String

Private _FechaAlta      As Date
Private _FechaMod       As Date
Private _FechaBaja      As Date

'INDICES DE CAMPOS DE TABLA GEN_CAT_GEN
Public Const BD_ID_CAT        As Integer = 0
Public Const BD_CLAVE         As Integer = 1
Public Const BD_VALOR         As Integer = 2
Public Const BD_DESCRIPCION   As Integer = 3
Public Const BD_FEC_ALTA      As Integer = 4
Public Const BD_FEC_MOD       As Integer = 5
Public Const BD_FEC_BAJA      As Integer = 6

#Region "Porpiedades de la clase"

Public Property IdCat As Integer
    Get
        IdCat = Me._IdCat
    End Get
    Set(ByVal value As Integer)
        Me._IdCat = value
    End Set
End Property

Public Property Descripcion As String
    Get
        Descripcion = Me._Descripcion
    End Get
    Set(ByVal value As String)
        Me._Descripcion = value
    End Set
End Property



Public Property Clave As Integer
    Get
        Clave = Me._Clave
    End Get    
    Set (ByVal value As Integer)
        Me._Clave = value
    End Set
End Property

Public Property Valor As String
    Get
         Valor = Me._Valor
    End Get    
    Set (ByVal value As String)
        Me._Valor = value
    End Set
End Property


Public Property FechaAlta As Date
    Get
         FechaAlta = Me._FechaAlta
    End Get    
    Set (ByVal value As Date)
        Me._FechaAlta = value
    End Set
End Property

Public Property FechaMod As Date
    Get
         FechaMod = Me._FechaMod
    End Get    
    Set (ByVal value As Date)
        Me._FechaMod = value
    End Set
End Property

Public Property FechaBaja As Date
    Get
         FechaBaja = Me._FechaBaja
    End Get    
    Set (ByVal value As Date)
        Me._FechaBaja = value
    End Set

End Property

Public Overrides Function ToString() As String
    Return Valor
End Function

#End Region

#Region "Porpiedades de la clase"

    Public Function ObtieneCatalogo(ByRef idCat As Integer) As List(Of CTCatalogoGenerico)
        Try
            Dim lstCatalogo As New List(Of CTCatalogoGenerico)
            Dim dtDatos      As DataTable = CFLServicioLocalSQLServerDB.ObtieneCatalogo(IdCat)
            Dim c            As CTCatalogoGenerico

            If dtDatos.Rows.Count > 0 Then
                For Each dt As DataRow In dtDatos.Rows
                    c = New CTCatalogoGenerico()
                    With c       
                        .IdCat             = Convert.ToInt32(dt(BD_ID_CAT))
                        .Clave             = Convert.ToInt32(dt(BD_CLAVE))
                        .Valor             = Convert.ToString(dt(BD_VALOR))
                        .Descripcion       = Convert.ToString(dt(BD_DESCRIPCION))
                        '.FechaAlta         = Convert.ToDateTime(dt(BD_FEC_ALTA))
                        '.FechaMod          = Convert.ToDateTime(dt(BD_FEC_MOD))
                        '.FechaBaja         = Convert.ToDateTime(dt(BD_FEC_BAJA))
                    End With
                    lstCatalogo.Add(c)
                    c = Nothing
                Next
            End If

            Return lstCatalogo
        Catch ex As Exception
            Throw ex
        End Try

   End Function

#End Region

End Class
